In the good old .NET 1.x days where Generics wasn’t born yet, the ArrayList was the class to use for just about any type of collection. It was much easier to use compared to an array of objects and it did the job very well. It was kind of the do-it-all solution for the lazy developer that just needed things to work the first time.

Along came the .NET Framework 2.0 which introduced Generics to the platform. Since the first beta of Visual Studio “Whidbey” was released more than two years ago, I’ve written a couple hundred thousand lines of code in C# 2.0 and not once used an ArrayList. Generic collections like Collection<> and List<> replaced the ArrayList completely from my code and that makes me wonder: Are there still a place for the ArrayList or is it dead?

If it is dead, why hasn’t Microsoft deprecated it with the [obsolete] attribute or at least made a note about it in the documentation? Because Microsoft doesn’t consider it being dead I wonder if I have missed something. Maybe there is a place for it in some obscure scenarios I just haven’t found yet, but I sincerely doubt there is.

So, is the ArrayList dead or not?

I remember when ASP.NET 2.0 beta 1 was released about 2 years ago and I eagerly tried it out. The first thing that struck me as strange was the new application folders like App_Code, App_Data, and App_Themes etc. They all made perfect sense except App_Code. I didn’t see the point of putting code in the folder because a separate assembly is a much cleaner approach.

After some weeks I finally got the point. It had nothing to do with putting code-behind files in it to make them globally accessible because that is just bad architecture. No, it was much more important than that. It was about componentizing ones application to an even smaller degree than by using and reusing separate assemblies. The App_Code folder allows me to use HttpModules, handlers, classes and other code pieces that don’t naturally belong together in a separate assembly.

By now a have a pretty decent collection of code that I use for various different ASP.NET applications and I can simply pick just the ones I need and drop them into the App_Code folder. That means that it is no longer necessary to reference a separate assembly and only use a couple of its classes. That makes the application easier to debug and you know exactly what code pieces you use at all times – just look in App_Code.

In ASP.NET 1.x none of this has any meaning because all classes can be made globally accessible without moving them to some special location. But in ASP.NET 2.0 this is a great way of abstracting components from the rest of the code. That's why App_Code is better. The only thing you have to do in order to get the full advantage is to start collecting reusable components.